package com.koron.css2.baseConfig.impl;

import com.koron.css2.ServerInterface;
import com.koron.css2.baseConfig.bean.ContractTemplateBean;
import com.koron.css2.baseConfig.mapper.ContractTemplateMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.CommonUtils;
import com.koron.util.Constant;
import com.koron.util.JsonUtils;
import com.koron.util.ValidationKey;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

public class ContractTemplateUpdate implements ServerInterface{

	@Override
	@ValidationKey(clazz = ContractTemplateBean.class,method = "insert")
	public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
		try {
			ContractTemplateBean bean = JsonUtils.objectToPojo(req.getData(),ContractTemplateBean.class);
			ContractTemplateMapper mapper = factory.getMapper(ContractTemplateMapper.class);
			bean.setUpdateName(userInfo.getUserInfo().getName());
			bean.setUpdateTime(CommonUtils.getCurrentTime());
			mapper.templateUpdate(bean);
		}catch(Exception e){
			logger.error("操作失败", e);
			return MessageBean.create(Constant.MESSAGE_INT_FAIL, "操作失败", void.class);
		}
		return MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "success", void.class);
	}

}
